(function( $ ) { 'use strict'; // Modernizr check: object fit if (typeof Modernizr == 'object') { if ( !Modernizr.objectfit ) { $('.object-fit-container').each(function () { var $container = $(this), imgUrl = $container.find('img').prop('src'); if (imgUrl) { $container .css('backgroundImage', 'url(' + imgUrl + ')') .addClass('compat-object-fit'); } }); } } // Preloader Setup if ($('.ankit-preloader--preloader-1').length) { var loader = new SVGLoader( document.getElementById( 'ankit-preloader' ), { speedIn : 600, easingIn : mina.easeinout } ); $(window).bind("load", function() { loader.hide(); }); // If it takes longer for window to load, timeout at 4 seconds setTimeout(function(){ if(document.readyState !== 'ready' && document.readyState !== 'complete') { loader.hide(); } }, 4000); } if ($('.ankit-preloader--preloader-4').length) { // Set preloader image height to make sure the elements overlap properly var preloader_img_height = $('.ankit-preloader__logo img').outerHeight(); $('.ankit-preloader__logo').css('height', preloader_img_height + 'px'); // Fade out Preloader on window fully loaded $(window).bind("load", function() { $('.ankit-preloader--preloader-4').fadeOut(); }); // If it takes longer for window to load, timeout at 4 seconds setTimeout(function(){ if(document.readyState !== 'ready' && document.readyState !== 'complete') { $('.ankit-preloader--preloader-4').fadeOut(); } }, 4000); } // Scroll Indicator // @since 0.4 if (('#progressBar').length) { $(window).on('scroll', function() { var winScroll = document.body.scrollTop || document.documentElement.scrollTop; var height = document.documentElement.scrollHeight - document.documentElement.clientHeight; var scrolled = (winScroll / height) * 100; $('#progressBar').css('width', scrolled + '%'); }); } })( jQuery ); function init_ad_maps() { // Init Maps jQuery('.ad-map').each(function(){ // create map map = new_map( jQuery(this) ); }); } /* * new_map * * This function will render a Google Map onto the selected jQuery element * * @type function * @date 8/11/2013 * @since 4.3.0 * * @param $el (jQuery element) * @return n/a */ function new_map( $el ) { // var var $markers = $el.find('.marker'); var map_styles= $el.find('.ad-map-style').html(); var map_zoom = $el.attr('data-zoom'); var map_controls = $el.attr('data-hide-controls'); map_controls = (map_controls == 'true'); map_styles = JSON.parse(decodeURIComponent(window.atob(map_styles))); // vars var args = { zoom : parseInt(map_zoom), center : new google.maps.LatLng(0, 0), mapTypeId : google.maps.MapTypeId.ROADMAP, styles : map_styles, disableDefaultUI : map_controls }; // create map var map = new google.maps.Map( $el[0], args); // add markers map.markers = []; $markers.each(function(){ add_marker( jQuery(this), map ); }); // center map center_map( map ); return map; } /* * add_marker * * This function will add a marker to the selected Google Map * * @type function * @date 8/11/2013 * @since 4.3.0 * * @param $marker (jQuery element) * @param map (Google Map object) * @return n/a */ function add_marker( $marker, map ) { var latlng = new google.maps.LatLng( $marker.attr('data-lat'), $marker.attr('data-lng') ); var marker_img = $marker.attr('data-icon'); // create marker var marker = new google.maps.Marker({ position : latlng, map : map, icon : marker_img }); // add to array map.markers.push( marker ); // if marker contains HTML, add it to an infoWindow if( $marker.html() ) { var infowindow = new google.maps.InfoWindow({ content : $marker.html() }); google.maps.event.addListener(marker, 'click', function() { infowindow.open( map, marker ); }); } } /* * center_map * * This function will center the map, showing all markers attached to this map * * @type function * @date 8/11/2013 * @since 4.3.0 * * @param map (Google Map object) * @return n/a */ function center_map( map ) { var bounds = new google.maps.LatLngBounds(); // loop through all markers and create bounds jQuery.each( map.markers, function( i, marker ){ var latlng = new google.maps.LatLng( marker.position.lat(), marker.position.lng() ); bounds.extend( latlng ); }); // only 1 marker? if( map.markers.length == 1 ) { // set center of map map.setCenter( bounds.getCenter() ); map.setZoom( 14 ); } else { // fit to bounds map.fitBounds( bounds ); } }